Skip to content

生成RSA密钥 - GenerateRSAKey

函数简介

生成RSA密钥对,包括公钥和私钥,支持多种格式和密钥大小。

接口名称

GenerateRSAKey

DLL调用

c
int GenerateRSAKey(long instance, string publicKeyPath, string privateKeyPath, int type, int keySize);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
publicKeyPath字符串公钥保存路径。
privateKeyPath字符串私钥保存路径。
type整数型类型:0-生成pem格式秘钥;1-生成xml格式秘钥;2-生成PKCS1格式秘钥。
keySize整数型密钥大小:512-512位;1024-1024位;2048-2048位;4096-4096位。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
cpp
var ola = com("OlaPlug.OlaSoft")
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GenerateRSAKey(long ola, string publicKeyPath, string privateKeyPath, int type, int keySize);

long instance = CreateCOLAPlugInterFace();
int ret = GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);
python
long instance = CreateCOLAPlugInterFace();
GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);

返回值

返回值说明
(返回值)成功返回0;失败返回其他值。

注意事项

项目说明
路径生成的密钥文件将保存到指定的路径。
使用2048位或更高位数的密钥以保证安全性建议使用2048位或更高位数的密钥以保证安全性。